#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX 1000 //so luong sinh vien toi da
//Khai bao cau truc
//Cau truc Hoten
struct hoten
{
       char hodem[25];
       char ten[10];
};
//Cau truc ngaysinh
struct ngaysinh
{
      unsigned char ngay; //int ngay;
      unsigned char thang; 
      unsigned int nam;
};
//Cau truc Monhoc
struct monhoc
{
       char tenmon[30];
       float kt1,kt2,cc,thi,tb; //Kiem tra 1, kiem tra 2, chuyen can, thi, trung binh
       unsigned char sotinchi;
};
//Cau truc Diem mon hoc
struct diemmonhoc
{
       monhoc laptrinh;
       monhoc csdl; //co so du lieu
       monhoc tienganh;
       monhoc nguyenlythongke;
};
//Cau truc Diem
struct diem
{
     unsigned char diemrenluyen;
     float dtb; //diem trung binh cac mon
     diemmonhoc dmh; //diem cac mon hoc  
};
//Cau truc sinh vien 
struct sinhvien
{
       char masv[10];
       hoten ht; //ho ten
       ngaysinh ns; //ngay sinh
       char qq[50];
       char khoa[30];
       char lop[10];
       diem d; //diem       
};
//Khai bao danh sach sinh vien
sinhvien ds[MAX];
int soluong; //so luong sinh vien thuc te
void nhaptubanphim()
{
     int i;
     printf("\nNhap so luong sinh vien: ");
     scanf("%d",&soluong);
     fflush(stdin); //xoa bo nho dem
     for (i=0;i<soluong;i++)
         {
           printf("\nNhap thong tin cua sinh vien thu %d: \n",i+1);
           printf("\nMa sinh vien: ");
           gets(ds[i].masv);
           printf("\nHo dem: ");
           gets(ds[i].ht.hodem);
           printf("\nTen: ");
           gets(ds[i].ht.ten);
           printf("\nNgay sinh: \n");
           printf("\nNgay: ");
           scanf("%d",&ds[i].ns.ngay);
           printf("\nThang: ");
           scanf("%d",&ds[i].ns.thang);
           printf("\nNam: ");
           scanf("%d",&ds[i].ns.nam);
           fflush(stdin);
           printf("\nQue quan: ");                                 
           gets(ds[i].qq);
           printf("Khoa: ");
           gets(ds[i].khoa);
           printf("Lop: ");
           gets(ds[i].lop);
           printf("\nDiem cac mon hoc\n");
           //Mon lap trinh
           printf("Ten mon lap trinh: ");
           gets(ds[i].d.dmh.laptrinh.tenmon);
           fflush(stdin);
           printf("Diem mon lap trinh\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&ds[i].d.dmh.laptrinh.kt1,
           &ds[i].d.dmh.laptrinh.kt2,&ds[i].d.dmh.laptrinh.cc,
           &ds[i].d.dmh.laptrinh.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&ds[i].d.dmh.laptrinh.sotinchi);
           //Tinh diem trung binh
           ds[i].d.dmh.laptrinh.tb=ds[i].d.dmh.laptrinh.kt1*0.15+
            ds[i].d.dmh.laptrinh.kt2*0.15 + 
            ds[i].d.dmh.laptrinh.cc*0.1+ 
            ds[i].d.dmh.laptrinh.thi*0.6;
          //Mon co so du lieu
           fflush(stdin);
           printf("Ten mon csdl: ");
           gets(ds[i].d.dmh.csdl.tenmon);
           fflush(stdin);
           printf("Diem mon csdl\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&ds[i].d.dmh.csdl.kt1,
           &ds[i].d.dmh.csdl.kt2,&ds[i].d.dmh.csdl.cc,
           &ds[i].d.dmh.csdl.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&ds[i].d.dmh.csdl.sotinchi);
           //Tinh diem trung binh
           ds[i].d.dmh.csdl.tb=ds[i].d.dmh.csdl.kt1*0.15+
            ds[i].d.dmh.csdl.kt2*0.15 + 
            ds[i].d.dmh.csdl.cc*0.1+ 
            ds[i].d.dmh.csdl.thi*0.6;  
          //Mon tieng Anh
           fflush(stdin);
           printf("Ten mon tieng Anh: ");
           gets(ds[i].d.dmh.tienganh.tenmon);
           fflush(stdin);
           printf("Diem mon tieng anh\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&ds[i].d.dmh.tienganh.kt1,
           &ds[i].d.dmh.tienganh.kt2,&ds[i].d.dmh.tienganh.cc,
           &ds[i].d.dmh.tienganh.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&ds[i].d.dmh.tienganh.sotinchi);
           //Tinh diem trung binh
           ds[i].d.dmh.tienganh.tb=ds[i].d.dmh.tienganh.kt1*0.15+
            ds[i].d.dmh.tienganh.kt2*0.15 + 
            ds[i].d.dmh.tienganh.cc*0.1+ 
            ds[i].d.dmh.tienganh.thi*0.6;
          //Diem ren luyen
          printf("\nDiem ren luyen: ");
          scanf("%d",&ds[i].d.diemrenluyen);
          //Tinh diem trung binh tat ca cac mon
          ds[i].d.dtb=(ds[i].d.dmh.laptrinh.sotinchi*
          ds[i].d.dmh.laptrinh.tb + ds[i].d.dmh.csdl.sotinchi*
          ds[i].d.dmh.csdl.tb+ ds[i].d.dmh.tienganh.sotinchi*
          ds[i].d.dmh.tienganh.tb)/(ds[i].d.dmh.laptrinh.sotinchi+
          ds[i].d.dmh.csdl.sotinchi+ds[i].d.dmh.tienganh.sotinchi);                                   
         fflush(stdin);
         }
}
void nhaptufile()
{
     int i;
     char tenfile[30];//ten file
     FILE *f;//Bien file
     printf("Nhap ten file");
     fflush(stdin);
     gets(tenfile);
     f=fopen(tenfile, "rb");//mo file do doc
     if(f==NULL)
     {
                printf("Khong tim thay file");
                return;
     }
     //ham sizeof:kich thuoc cua bien
     fread(&soluong,sizeof(soluong),1,f);
     for(i=0;i<soluong;i++)
        fread(&ds[i],sizeof(ds[i]),1,f);
     fclose(f);     
}
void luufile()
{
    int i;
     char tenfile[30];//ten file
     FILE *f;//Bien file
     printf("Nhap ten file");
     fflush(stdin);
     gets(tenfile);
     f=fopen(tenfile, "wb");//mo file do doc
     if(f==NULL)
     {
                printf("Khong the mo file de ghi ");
                return;
     }
     //ham sizeof:kich thuoc cua bien
     fwrite(&soluong,sizeof(soluong),1,f);
     for(i=0;i<soluong;i++)
        fwrite(&ds[i],sizeof(ds[i]),1,f);
     fclose(f);        
}
void indanhsach()
{
     int i;
     printf("\nDANH SACH SINH VIEN TOAN TRUONG\n");
     printf("STT   MASV      HO DEM       TEN       NGAYSINH         DIEMTB    DIEMRENLUYEN\n");
     for (i=0;i<soluong;i++)
     {
         printf("%5d %s%10s%10s         %d/%d/%d     %8.1f    %10d\n",
         i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,
         ds[i].ns.ngay,ds[i].ns.thang, ds[i].ns.nam,
         ds[i].d.dtb,ds[i].d.diemrenluyen); 
     }         
}
void indstheokhoa()
{
     char tenkhoa[30];
     int i;
     fflush(stdin);
     printf("\nBan muon in danh sach sinh vien cua khoa nao? ");
     gets(tenkhoa);     
     printf("\nDANH SACH SINH VIEN CUA KHOA %s\n",tenkhoa);
     printf("STT MASV      HO DEM                 TEN     NGAYSINH  DIEMTB  DIEMRENLUYEN\n");
     for (i=0;i<soluong;i++)
     {
         if(strcmp(tenkhoa,ds[i].khoa)==0)
         {
           printf("%3d %s%20s%10s  %d/%d/%d  %6.1f%10d\n",
             i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,
             ds[i].ns.ngay,ds[i].ns.thang, ds[i].ns.nam,
             ds[i].d.dtb,ds[i].d.diemrenluyen); 
         }
     }   
}
void indstheolop()
{
     char tenlop[30];
     int i;
     fflush(stdin);
     printf("\nBan muon in danh sach sinh vien cua lop nao? ");
     gets(tenlop);     
     printf("\nDANH SACH SINH VIEN CUA LOP %s\n",tenlop);
     printf("STT MASV      HO DEM                 TEN     NGAYSINH  DIEMTB  DIEMRENLUYEN\n");
     for (i=0;i<soluong;i++)
     {
         if(strcmp(tenlop,ds[i].lop)==0)
         {
           printf("%3d %s%20s%10s  %d/%d/%d  %6.1f%10d\n",
             i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,
             ds[i].ns.ngay,ds[i].ns.thang, ds[i].ns.nam,
             ds[i].d.dtb,ds[i].d.diemrenluyen); 
         }
     } 
}
void timkiemtheoten()
{
     char ten[30];
     int i;
     fflush(stdin);
     printf("\n hay nhap ten sv can tim kiem");
     gets(ten);
     printf("\n ds sinh vien co ten la %s",ten);
     printf("\nSTT MASV HODEM TEN NGAYSINH QUE KHOA LOP\n");
     for(i=0;i<soluong;i++)
     {
     if(strcmp(ten,ds[i].ht.ten)==0)
     printf("\n%d%s%5s%3s%d/%d/%d%3s%2s%2s\n",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].qq,ds[i].khoa,ds[i].lop);
     }
}
void timkiemtheomasv()
{
     char masinhvien[30];
     int i;
     fflush(stdin);
     printf("\n hay nhap ma sinh vien can tim kiem");
     gets(masinhvien);
     printf("\n ds sinh vien co masv la %s",masinhvien);
     printf("\nSTT MASV HODEM TEN NGAYSINH QUE KHOA LOP\n");
     for(i=0;i<soluong;i++)
     {
     if(strcmp(masinhvien,ds[i].masv)==0)
     printf("\n%d%s%5s%3s%d/%d/%d%3s%2s%2s\n",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].qq,ds[i].khoa,ds[i].lop);
     }
}
void sapxeptheoten()
{
     int i,j;
     sinhvien tg;
     for(i=0;i<soluong-1;i++)
     for(j=i+1;j<soluong;j++)
     if(strcmp(ds[i].ht.ten,ds[j].ht.ten)>0)
     {
      tg=ds[i];
      ds[i]=ds[j];
      ds[j]=tg;
     }
     printf("\nSTT MASV HODEM TEN NGAYSINH DIEMTRUNGBINH\n");
     for(i=0;i<soluong;i++)
     printf("\n%d%s%5s%3s%d/%d/%d%6.2f\n",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].d.dtb);
}
void sapxeptheodtb()
{
     int i,j;
     sinhvien tg;
     for(i=0;i<soluong-1;i++)
     for(j=i+1;j<soluong;j++)
     if(ds[i].d.dtb<ds[j].d.dtb)
     {
      tg=ds[i];
      ds[i]=ds[j];
      ds[j]=tg;
     }
     printf("\nSTT MASV HODEM TEN NGAYSINH DIEMTRUNGBINH\n");
     for(i=0;i<soluong;i++)
     printf("%d%s%5s%3s%d/%d/%d%6.2f\n",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].d.dtb);
     
}
void sapxeptheomasv()
{
     int i,j;
     sinhvien tg;
     for(i=0;i<soluong-1;i++)
     for(j=i+1;j<soluong;j++)
     if(strcmp(ds[i].masv,ds[j].masv)>0)
     {
      tg=ds[i];
      ds[i]=ds[j];
      ds[j]=tg;
     }
     printf("\nSTT MASV HODEM TEN NGAYSINH DIEMTRUNGBINH\n");
     for(i=0;i<soluong;i++)
     printf("%d%s%5s%3s%d/%d/%d%6.2f",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].d.dtb);
     
}
void them()
{
           sinhvien x;
           printf("\nNhap thong tin cua sinh vien thu %d: \n");
           fflush(stdin);
           printf("\nMa sinh vien: ");
           gets(x.masv);
           printf("\nHo dem: ");
           gets(x.ht.hodem);
           printf("\nTen: ");
           gets(x.ht.ten);
           printf("\nNgay sinh: \n");
           printf("\nNgay: ");
           scanf("%d",&x.ns.ngay);
           printf("\nThang: ");
           scanf("%d",&x.ns.thang);
           printf("\nNam: ");
           scanf("%d",&x.ns.nam);
           fflush(stdin);
           printf("\nQue quan: ");                                 
           gets(x.qq);
           printf("Khoa: ");
           gets(x.khoa);
           printf("Lop: ");
           gets(x.lop);
           printf("\nDiem cac mon hoc\n");
           //Mon lap trinh
           printf("Ten mon lap trinh: ");
           gets(x.d.dmh.laptrinh.tenmon);
           fflush(stdin);
           printf("Diem mon lap trinh\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&x.d.dmh.laptrinh.kt1,
           &x.d.dmh.laptrinh.kt2,&x.d.dmh.laptrinh.cc,
           &x.d.dmh.laptrinh.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&x.d.dmh.laptrinh.sotinchi);
           //Tinh diem trung binh
           x.d.dmh.laptrinh.tb=x.d.dmh.laptrinh.kt1*0.15+
            x.d.dmh.laptrinh.kt2*0.15 + 
            x.d.dmh.laptrinh.cc*0.1+ 
            x.d.dmh.laptrinh.thi*0.6;
          //Mon co so du lieu
           fflush(stdin);
           printf("Ten mon csdl: ");
           gets(x.d.dmh.csdl.tenmon);
           fflush(stdin);
           printf("Diem mon csdl\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&x.d.dmh.csdl.kt1,
           &x.d.dmh.csdl.kt2,&x.d.dmh.csdl.cc,
           &x.d.dmh.csdl.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&x.d.dmh.csdl.sotinchi);
           //Tinh diem trung binh
           x.d.dmh.csdl.tb=x.d.dmh.csdl.kt1*0.15+
            x.d.dmh.csdl.kt2*0.15 + 
            x.d.dmh.csdl.cc*0.1+ 
            x.d.dmh.csdl.thi*0.6;  
          //Mon tieng Anh
           fflush(stdin);
           printf("Ten mon tieng Anh: ");
           gets(x.d.dmh.tienganh.tenmon);
           fflush(stdin);
           printf("Diem mon tieng anh\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&x.d.dmh.tienganh.kt1,
           &x.d.dmh.tienganh.kt2,&x.d.dmh.tienganh.cc,
           &x.d.dmh.tienganh.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&x.d.dmh.tienganh.sotinchi);
           //Tinh diem trung binh
           x.d.dmh.tienganh.tb=x.d.dmh.tienganh.kt1*0.15+
            x.d.dmh.tienganh.kt2*0.15 + 
            x.d.dmh.tienganh.cc*0.1+ 
            x.d.dmh.tienganh.thi*0.6;
          //Diem ren luyen
          printf("\nDiem ren luyen: ");
          scanf("%d",&x.d.diemrenluyen);
          //Tinh diem trung binh tat ca cac mon
          x.d.dtb=(x.d.dmh.laptrinh.sotinchi*
          x.d.dmh.laptrinh.tb +x.d.dmh.csdl.sotinchi*
          x.d.dmh.csdl.tb+ x.d.dmh.tienganh.sotinchi*
          x.d.dmh.tienganh.tb)/(x.d.dmh.laptrinh.sotinchi+
          x.d.dmh.csdl.sotinchi+x.d.dmh.tienganh.sotinchi);                                   
         fflush(stdin);
         // chen them sinh vien vao cuoi danh sach
         ds[soluong]=x;//chen vao cuoi
         soluong=soluong+1;
}
void sua()
{
     sinhvien x;
     char masv[10];//Ma sinh vien can sua
     printf("Nhap ma sinh vien can sua: ");
     fflush(stdin);
     gets(masv);
     int i,vt,found=0;
     for(i=0;i<soluong;i++)
     if(strcmp(ds[i].masv,masv)==0)
     {
                                   vt=i;
                                   found =1;
                                   break;
                                   }
     if(found==0)
     printf("Khong tim thay sinh vien can sua\n");
     else 
     {
          strcpy(x.masv,masv);//luu lai ma sinh vien
           printf("\nHo dem: ");
           gets(x.ht.hodem);
           printf("\nTen: ");
           gets(x.ht.ten);
           printf("\nNgay sinh: \n");
           printf("\nNgay: ");
           scanf("%d",&x.ns.ngay);
           printf("\nThang: ");
           scanf("%d",&x.ns.thang);
           printf("\nNam: ");
           scanf("%d",&x.ns.nam);
           fflush(stdin);
           printf("\nQue quan: ");                                 
           gets(x.qq);
           printf("Khoa: ");
           gets(x.khoa);
           printf("Lop: ");
           gets(x.lop);
           printf("\nDiem cac mon hoc\n");
           //Mon lap trinh
           printf("Ten mon lap trinh: ");
           gets(x.d.dmh.laptrinh.tenmon);
           fflush(stdin);
           printf("Diem mon lap trinh\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&x.d.dmh.laptrinh.kt1,
           &x.d.dmh.laptrinh.kt2,&x.d.dmh.laptrinh.cc,
           &x.d.dmh.laptrinh.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&x.d.dmh.laptrinh.sotinchi);
           //Tinh diem trung binh
           x.d.dmh.laptrinh.tb=x.d.dmh.laptrinh.kt1*0.15+
            x.d.dmh.laptrinh.kt2*0.15 + 
            x.d.dmh.laptrinh.cc*0.1+ 
            x.d.dmh.laptrinh.thi*0.6;
          //Mon co so du lieu
           fflush(stdin);
           printf("Ten mon csdl: ");
           gets(x.d.dmh.csdl.tenmon);
           fflush(stdin);
           printf("Diem mon csdl\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&x.d.dmh.csdl.kt1,
           &x.d.dmh.csdl.kt2,&x.d.dmh.csdl.cc,
           &x.d.dmh.csdl.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&x.d.dmh.csdl.sotinchi);
           //Tinh diem trung binh
           x.d.dmh.csdl.tb=x.d.dmh.csdl.kt1*0.15+
            x.d.dmh.csdl.kt2*0.15 + 
            x.d.dmh.csdl.cc*0.1+ 
            x.d.dmh.csdl.thi*0.6;  
          //Mon tieng Anh
           fflush(stdin);
           printf("Ten mon tieng Anh: ");
           gets(x.d.dmh.tienganh.tenmon);
           fflush(stdin);
           printf("Diem mon tieng anh\n");
           printf("Diem kiem tra 1, kiem tra 2, chuyen can, thi: ");
           scanf("%f%f%f%f",&x.d.dmh.tienganh.kt1,
           &x.d.dmh.tienganh.kt2,&x.d.dmh.tienganh.cc,
           &x.d.dmh.tienganh.thi);
           printf("\nSo tin chi: ");
           scanf("%d",&x.d.dmh.tienganh.sotinchi);
           //Tinh diem trung binh
           x.d.dmh.tienganh.tb=x.d.dmh.tienganh.kt1*0.15+
            x.d.dmh.tienganh.kt2*0.15 + 
            x.d.dmh.tienganh.cc*0.1+ 
            x.d.dmh.tienganh.thi*0.6;
          //Diem ren luyen
          printf("\nDiem ren luyen: ");
          scanf("%d",&x.d.diemrenluyen);
          //Tinh diem trung binh tat ca cac mon
          x.d.dtb=(x.d.dmh.laptrinh.sotinchi*
          x.d.dmh.laptrinh.tb +x.d.dmh.csdl.sotinchi*
          x.d.dmh.csdl.tb+ x.d.dmh.tienganh.sotinchi*
          x.d.dmh.tienganh.tb)/(x.d.dmh.laptrinh.sotinchi+
          x.d.dmh.csdl.sotinchi+x.d.dmh.tienganh.sotinchi);                                   
         fflush(stdin);
         // cap nhat du lieu
         ds[vt]=x;//cap nhat
         luufile();
         printf("Da cap nhat du lieu thanh cong roi nhe!");
         getch();
         } 
}
void xoa()
{
    char masv[10];//Ma sinh vien can sua
     printf("Nhap ma sinh vien can xoa: ");
     fflush(stdin);
     gets(masv);
     int i,vt,found=0;
     char traloi;//xac  nhan xoa hay khong?
     for(i=0;i<soluong;i++)
     if(strcmp(ds[i].masv,masv)==0)
     {
                                   vt=i;
                                   found =1;
                                   break;
                                   }
     if(found==0)
     printf("Khong tim thay sinh vien can xoa\n");
     else 
     {  
          //Thuc hien xoa
          printf("Ban co muon xoa sinh vien co ma la %s hay khong (C/K)",masv);
          scanf("%c",&traloi);
          if((traloi=='C')||(traloi=='c'))
          {
          for(i=vt;i<soluong;i++)
          ds[i]=ds[i+1];
          soluong=soluong-1;
          luufile();
          }
     }
}
void indskhoaluan()
{
       int i;
     printf("\n DANH SACH SINH VIEN DUOC VIET KHOA LUAN LA:\n");
     printf("\nSTT MASV HODEM TEN NGAYSINH DIEMTRUNGBINH  DIEM REN LUYEN\n");
     for(i=0;i<soluong;i++)
     if((ds[i].d.dtb>8))
     printf("\n%d%s%5s%3s%d/%d/%d%6.2f %d\n",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].d.dtb,ds[i].d.diemrenluyen);
     
}
void indstotnghiep()
{
     int i;
     printf("\n DANH SACH SINH VIEN DUOC TOT NGHIEP LA:\n");
     printf("\nSTT MASV HODEM TEN NGAYSINH DIEMTRUNGBINH  DIEM REN LUYEN\n");
     for(i=0;i<soluong;i++)
     if((ds[i].d.dtb>5))
     
     printf("\n%d%s%5s%3s%d/%d/%d%6.2f %d\n",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].d.dtb,ds[i].d.diemrenluyen);
     
}
void indshocbong()
{
     int i;
     printf("\n DANH SACH SINH VIEN DUOC HOC BONG LA:\n");
     printf("\nSTT MASV HODEM TEN NGAYSINH DIEMTRUNGBINH  DIEM REN LUYEN\n");
     for(i=0;i<soluong;i++)
     if((ds[i].d.dtb>9)&&(ds[i].d.diemrenluyen>90))
     
     printf("\n%d%s%5s%3s%d/%d/%d%6.2f %d\n",i+1,ds[i].masv,ds[i].ht.hodem,ds[i].ht.ten,ds[i].ns.ngay,ds[i].ns.thang,ds[i].ns.nam,ds[i].d.dtb,ds[i].d.diemrenluyen);
     
}
//Cac menu
void menunhap()
{
     int traloi;
     printf("\n1. Nhap tu ban phim");
     printf("\n2. Nhap tu file");
     printf("\n3. Luu ra file");
     printf("\nMoi ban chon chuc nang: ");
     scanf("%d",&traloi);
     switch (traloi)
     {
            case 1: nhaptubanphim(); break;
            case 2: nhaptufile(); break;
            case 3: luufile(); break;
     }
}
void menuinds()
{
     int traloi;
     printf("\n1. In toan bo danh sach");
     printf("\n2. In danh sach theo khoa");
     printf("\n3. In danh sach theo lop");
     printf("\nMoi ban chon chuc nang: ");
     scanf("%d",&traloi);
     switch (traloi)
     {
            case 1: indanhsach(); break;
            case 2: indstheokhoa(); break;
            case 3: indstheolop(); break;
     }
}
void menutimkiem()
{
     int traloi;
     printf("\n1. Tim kiem theo ten");
     printf("\n2. Tim kiem theo ma sv");
     printf("\nMoi ban chon chuc nang: ");
     scanf("%d",&traloi);
     switch (traloi)
     {
            case 1: timkiemtheoten(); break;
            case 2: timkiemtheomasv(); break;
            
     }
}
void menusapxep()
{
     int traloi;
     printf("\n1. Sap xep theo ten");
     printf("\n2. Sap xep theo diem trung binh");
     printf("\n3. Sap xep theo ma sinh vien");
     printf("\nMoi chon chuc nang : ");
     scanf("%d",&traloi);
     switch (traloi)
     {
            case 1: sapxeptheoten(); break;
            case 2: sapxeptheodtb(); break;
            case 3: sapxeptheomasv();break;
            
     }
}
void menucapnhat()
{ 
     int traloi;
     printf("\n1.Chen them sinh vien ");
     printf("\n2. sua thong tin sinh vien");
     printf("\n3. Xoa thong tin sinh vien");
     printf("\nMoi chon chuc nang : ");
     scanf("%d",&traloi);
     switch (traloi)
     {
            case 1: them(); break;
            case 2: sua(); break;
            case 3: xoa();break;
     }
}
void menubaocao()
{
     int traloi;
     printf("\n1. In danh sach hoc bong");
     printf("\n2. In danh sach khoa luan");
     printf("\n3. In danh sach tot nghiep");
     printf("\nMoi chon chuc nang : ");
     scanf("%d",&traloi);
     switch (traloi)
     {
            case 1: indshocbong(); break;
            case 2: indskhoaluan(); break;
            case 3: indstotnghiep();break;
            
     }
}
void menu()
{
     int traloi;
     while (1)
     {
           printf("\n       CHUONG TRINH QUAN LY DIEM SINH VIEN\n");
           printf("\n           ----------------------\n");
           printf("\n1. Nhap danh sach");
           printf("\n2. In danh sach");
           printf("\n3. Tim kiem");
           printf("\n4. Sap xep");
           printf("\n5. Cap nhat");
           printf("\n6. Bao cao");
           printf("\n7. Thoat");
           printf("\nMoi ban chon chuc nang bang cach nhan phim so tuong ung ");
           scanf("%d",&traloi);
           switch (traloi)
           {
                  case 1: menunhap(); break;
                  case 2: menuinds(); break;
                  case 3: menutimkiem(); break;
                  case 4: menusapxep(); break;
                  case 5: menucapnhat(); break;
                  case 6: menubaocao(); break;
                  case 7: exit(1); break;
           }
     }
}
int main()
{
    menu();
}








